package com.david.warehouse.mapper;

import com.david.warehouse.pojo.entity.Category;
import com.david.warehouse.pojo.entity.Type;
import com.david.warehouse.pojo.vo.CategoryCasVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface CategoryMapper {

    @Insert("insert into whm_product_category (name,type_id, parent_id) VALUES (#{name},#{typeId}, #{parentId})")
    void insertCategory(String name,Integer typeId, Integer parentId);


    List<CategoryCasVO> getCategoryListByTypeId(Integer typeId);

    @Select("select id, name from whm_wh_type where name = #{type}")
    Type selectType(String type);

    @Update("update whm_product_category set name=#{name} where id=#{id}")
    void updateCategory(Integer id, String name);

    @Select("select id, name, type_id, parent_id from whm_product_category where parent_id = #{id}")
    List<Category> selectCategoryByParentId(Integer id);

    @Delete("delete from whm_product_category where id = #{id}")
    void deleteCategoryById(Integer id);
}
